package org.dbi.beans;

import java.util.Date;

import org.dbi.logger.ErrorLogger;


public class Attribute {
	private String naam = "";
	
	private boolean mandatory = false;
	//columnType wordt gecast naar string int bool enz.
	private Object columnType = null;
	private ErrorLogger logger = ErrorLogger.getLogger(getClass().getName());

	
	public Attribute(String naam, 	String columnType, boolean mandatory) {
		this.naam = naam;
		setColumnType(columnType);
		this.mandatory = mandatory;


	}

	public String getNaam() {
		return naam;
	}

	public void setNaam(String naam) {
		this.naam = naam;
	}

	private void setColumnType(String columnTyp) {
	

		if (columnTyp.toLowerCase().equals("varchar")) {
			this.columnType = new String("String");
		} else if (columnTyp.toLowerCase().equals("tinyint")) {
			this.columnType = new Boolean(null);
		} else if (columnTyp.toLowerCase().equals("integer")) {
			this.columnType = new Integer(0);
		}else if(columnTyp.toLowerCase().equals("date")){
			this.columnType = new Date();
		}else{
			logger.info("columnType wordt niet ondersteund door ons programma: "
					
					+ getNaam() + " --> " + columnType);
		}
	}

	public boolean isMandatory() {
		return mandatory;
	}

	public void setMandatory(boolean mandatory) {
		this.mandatory = mandatory;
	}
	
	public Object getColumnType(){
		return columnType;
	}
}
